//
//  GizUtil.m
//  Mahjong
//
//  Created by 饶首建 on 17/6/16.
//  Copyright © 2017年 com.ikamobile.com. All rights reserved.
//

#import "GizUtil.h"

#import <GizWifiSDK/GizWifiSDK.h>

//达人 12efcbfc9066436e99fbc448d9e5f4d3 b098e1b2713b48cba843bcbfaa6cc296
//Test01 f3045d48f1b04831a8f3ac7787a711e6 a3cd3641d4334980b8735a6cad21ef17

static NSString *appId = @"f3045d48f1b04831a8f3ac7787a711e6";
static NSString *appSecret = @"a3cd3641d4334980b8735a6cad21ef17";

@interface GizUtil()<GizWifiSDKDelegate>

@end

@implementation GizUtil

+(instancetype)sharedInstance{
    static dispatch_once_t onceToken;
    static GizUtil *gizUtil = nil;
    dispatch_once(&onceToken, ^{
        gizUtil = [[GizUtil alloc]init];
    });
    return gizUtil;
}
    
- (instancetype)init{
    self = [super init];
    if (self) {
        [GizWifiSDK sharedInstance].delegate = self;
        [GizWifiSDK startWithAppID:appId appSecret:appSecret specialProductKeys:nil cloudServiceInfo:nil autoSetDeviceDomain:NO];
    }
    return self;
}
    
#pragma mark - GizWifiSDKDelegate

- (void)wifiSDK:(GizWifiSDK *)wifiSDK didNotifyEvent:(GizEventType)eventType eventSource:(id)eventSource eventID:(GizWifiErrorCode)eventID eventMessage:(NSString *)eventMessage{
    if(eventType == GizEventSDK) {
        // SDK发生异常的通知
        NSLog(@"SDK event happened: [%@] = %@", @(eventID), eventMessage);
    } else if(eventType == GizEventDevice) {
        // 设备连接断开时可能产生的通知
        GizWifiDevice* mDevice = (GizWifiDevice*)eventSource;
        NSLog(@"device mac %@ disconnect caused by %@", mDevice.macAddress, eventMessage);
    } else if(eventType == GizEventM2MService) {
        // M2M服务返回的异常通知
        NSLog(@"M2M domain %@ exception happened: [%@] = %@", (NSString*)eventSource, @(eventID), eventMessage);
    } else if(eventType == GizEventToken) {
        // token失效通知
        NSLog(@"token %@ expired: %@", (NSString*)eventSource, eventMessage);
    }
}
    
    
    
    
    
    
    
    
    
    

    
@end
